Skip to content

fix(datasource): persist runtime datasources across restart#2096

Merged
xuyushun441-sys merged 1 commit into
mainfrom
feat/datasource-runtime-persistence
Jun 21, 2026
Merged

fix(datasource): persist runtime datasources across restart#2096
xuyushun441-sys merged 1 commit into
mainfrom
feat/datasource-runtime-persistence

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Problem

A UI-created (runtime) datasource vanished on backend restart. Root cause: datasource-admin persists via MetadataManager.register(), which is in-memory only unless a writable datasource: loader is wired — and standalone serve wires none. (Runtime objects survive because the protocol writes them straight to sys_metadata; datasources never used that durable path.)

Fix

Self-contained in the datasource-admin plugin — no change to global register() semantics, no protocol surgery:

  • On write: also persist the record to the durable sys_metadata table via the data engine (same store + row shape runtime objects use); remove the row on delete. Only the opaque external.credentialsRef is stored — never credential cleartext.
  • On boot (start(), before pool rehydration): restore persisted runtime datasources from sys_metadata back into the registry, so listDatasources() + pool rebuild see them. Code-defined (artifact) datasources are unaffected.
  • Degrades gracefully to the prior in-memory behavior when no data engine is present.

Verification

  • Unit: +2 tests (create → simulated restart → restored; delete removes the durable row); service-datasource 65/65 green.
  • Live: created a runtime sqlite datasource, confirmed it's written to sys_metadata, restarted the backend, and it survived (PERSISTED ACROSS RESTART: True).

Pairs with

The Studio datasource-via-metadata-admin-engine work (objectui #1846 + framework #2091).

🤖 Generated with Claude Code

UI-created (runtime) datasources vanished on a node restart: datasource-admin
persists via MetadataManager.register(), which is in-memory only unless a
writable `datasource:` loader is wired — and standalone `serve` wires none.
(Runtime objects survive because the protocol writes them straight to
sys_metadata; datasources never touched that durable path.)

Fix, self-contained in the datasource-admin plugin (no change to global
register() semantics, no protocol surgery):
- On write, persist the record to the durable `sys_metadata` table via the data
  engine (same store + row shape objects use) in addition to the in-memory
  register; remove the row on delete. Only the opaque `external.credentialsRef`
  is stored — never credential cleartext.
- On boot (`start()`, before pool rehydration) restore persisted runtime
  datasources from sys_metadata back into the registry, so `listDatasources()`
  and pool rebuild see them. Code-defined (artifact) datasources are unaffected.
- Degrades gracefully to prior in-memory behavior when no data engine is present.

Tests: +2 (persist→restart→restored; delete removes the durable row); service-
datasource 65 green. Verified live: created a runtime datasource, restarted the
backend, it survived (PERSISTED ACROSS RESTART).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 21, 2026 6:41am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): packages/services.

5 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/guides/packages.mdx (via packages/services)
  • content/docs/guides/runtime-services/audit-service.mdx (via packages/services)
  • content/docs/guides/runtime-services/index.mdx (via packages/services)
  • content/docs/guides/runtime-services/settings-service.mdx (via packages/services)
  • content/docs/protocol/objectos/i18n-standard.mdx (via packages/services)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@xuyushun441-sys
xuyushun441-sys merged commit 26d7df4 into main Jun 21, 2026
16 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the feat/datasource-runtime-persistence branch June 21, 2026 06:44
xuyushun441-sys added a commit that referenced this pull request Jun 21, 2026
…tion (#2112)

The README mentioned "REST routes under /api/v1/datasources" but didn't
enumerate them, and predated the Studio integration. Add:
- a REST routes section (lifecycle + drivers catalog + by-name test + GET :name
  detail + introspection/sync routes), with the credential-split note;
- a Studio integration section: datasource is managed through the metadata-admin
  engine (Setup → Integrations → Datasources), runtime records persist to
  sys_metadata and rehydrate on restart.

Reflects #2083 (drivers), #2085 (remote-tables/object-draft/by-name test),
#2086 (GET :name), #2091 (Setup nav), #2096 (persistence).

Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants